<?php

class Application_Form_Multimediafile extends Zend_Form
{
    public function init()
    {
        $this->setName('Multimediafile');
        
        $file_id = new Zend_Form_Element_Hidden('file_id');
        $file_id->addFilter('Int');
        
        $category_id = new Zend_Form_Element_Select('category_id');
        $category_id->setLabel('Chuyên mục')
        	    ->addFilter('Int');	
        
        $title = new Zend_Form_Element_Text('title');
        $title->setLabel('Tiêu đề')
              ->setRequired(true)
              ->addFilter('StripTags')
              ->addFilter('StringTrim')
              ->addValidator('NotEmpty');
              
        $slug = new Zend_Form_Element_Text('slug');
        $slug->setLabel('Slug')
               ->setRequired(true)
               ->addFilter('StripTags')
               ->addFilter('StringTrim')
               ->addValidator('NotEmpty');
        $description = new Zend_Form_Element_Textarea('description');
        $description->setLabel('Mô tả')
               ->setRequired(true)
               ->addFilter('StripTags')
               ->addFilter('StringTrim')
               ->addValidator('NotEmpty');
	$content = new Zend_Form_Element_Textarea('content');
        $content->setLabel('Nội dung')
               ->setRequired(true)
               ->addFilter('StripTags')
               ->addFilter('StringTrim')
               ->addValidator('NotEmpty');
        $allow_comment = new Zend_Form_Element_Select('allow_comment');
        $allow_comment->setLabel('Cho phép bình luận')
                ->setRequired(true)
                ->addMultiOptions(array(
                 	'0' => 'Không',
                	'1' => 'Cho phép'
          ));	       	
	$file_type = new Zend_Form_Element_Select('file_type');
        $file_type->setLabel('Loại file')
                ->setRequired(true)
                ->addMultiOptions(array(
                 	'audio' => 'Âm thanh',
                	'image' => 'Hình',
                	'video' => 'Video',
                	
        ));	
        $entityfile = new Zend_Form_Element_File('entityfile'); 
        $entityfile->setLabel('Chọn file:') 
                   ->setDestination(ROOT_PUBLIC_MEDIA_UPLOAD_IMAGES);
        $entityfile->addValidator('Count', false, 1); // only one file
        $entityfile->addValidator('Size', false, 102400000); //500Kb
        $entityfile->addValidator('Extension', false, 'jpg,png,gif,mp4,flv,wmv');
        
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id', 'AddButton');

        $cancel = new Zend_Form_Element_Submit('cancel');
        $cancel->setAttrib('id', 'CancelButton');
        
        $this->addElements(array($category_id, $title, $slug,$description, $content,$allow_comment, $file_type, $entityfile, $file_id,   $submit, $cancel));
    }
}